@extends('layouts.admin')
@push('morecss')
    <!-- Bootstrap Treeview -->
    <link rel="stylesheet" type="text/css" href="{{ asset('/vendor/bootstrap-treeview/dist/bootstrap-treeview.min.css') }}" />
    <!-- fontIconPicker core CSS -->
    <link rel="stylesheet" type="text/css" href="{{ asset('/vendor/fontIconPicker/css/jquery.fonticonpicker.min.css') }}" />
    <link rel="stylesheet" type="text/css" href="{{ asset('/vendor/fontIconPicker/themes/bootstrap-theme/jquery.fonticonpicker.bootstrap.min.css') }}" />
@endpush
@push('morescript')
    <!-- Bootstrap Treeview -->
    <script src="{{ asset('/vendor/bootstrap-treeview/dist/bootstrap-treeview.min.js') }}"></script>
    <!-- fontIconPicker JS -->
    <script type="text/javascript" src="{{ asset('/vendor/fontIconPicker/jquery.fonticonpicker.min.js') }}"></script>
    <script type="application/javascript">
        let page_params = {
            @can('admin.wxmaterialcategory.index')
            url_list: '{{ route('admin.wxmaterialcategory.index') }}',
            @endcan
            @can('admin.wxmaterialcategory.create')
            url_add: '{{ route('admin.wxmaterialcategory.create') }}',
            @endcan
            @can('admin.wxmaterialcategory.update')
            url_edit: '{{ route('admin.wxmaterialcategory.update') }}',
            @endcan
            @can('admin.wxmaterialcategory.destroy')
            url_del: '{{ route('admin.wxmaterialcategory.destroy') }}',
            @endcan
        };
    </script>
    <!-- require page js -->
    <script src="{{ mix('js/admin/wxmaterialcategory_index.js') }}"></script>
@endpush
@section('content')
    <!-- 主体内容 -->
    <div class="wrapper wrapper-content  animated fadeInRight">
        <div class="ibox-content m-b-sm border-bottom">
            <div class="row">
                <div class="col-sm-2">
                    <div class="form-group">
                        <label class="control-label" for="product_name">&nbsp;&nbsp;</label>
                        <div>
                            @can('admin.wxmaterialcategory.create')
                            <button class="btn btn-primary" type="button" id="btn-add" v-on:click="add"><i class="fa fa-plus"></i>
                                添加顶级分类
                            </button>
                            @endcan
                        </div>
                    </div>
                </div>
                <div class="col-sm-4 col-sm-offset-4">
                    <div class="form-group">
                        <label class="control-label" for="product_name">素材类别</label>
                        <select class="form-control" name="material_type" id="material_type" v-model="material_type">
                            @foreach ($materialType as $typeKey => $typeName)
                            <option value="{{ $typeKey }}">{{ $typeName }}</option>
                            @endforeach
                        </select>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-lg-12">
                <div class="ibox ">
                    <div class="ibox-title">
                        <h5>分类列表</h5>
                    </div>
                    <div class="ibox-content">
                        <div class="treeview" id="tree"></div>
                    </div>

                </div>
            </div>
        </div>
    </div>

<!-- 节点操作询问层 -->
<div class="ibox-content" id="box_ask" style="display: none">
    <div class="form-horizontal m-t">
        <div class="form-group" style="text-align: center">
            @can('admin.wxmaterialcategory.create')
            <button class="btn btn-success" type="button" id="btn-add-child" v-on:click="addChild">
                <i class="fa fa-plus"></i>
                添加子分类
            </button>
            @endcan
            @can('admin.wxmaterialcategory.update')
            <button class="btn btn-primary" type="button" id="btn-edit" v-on:click="edit">
                <i class="fa fa-edit"></i>
                编辑分类
            </button>
            @endcan
            @can('admin.wxmaterialcategory.destroy')
            <button class="btn btn-danger" type="button" id="btn-del" v-on:click="del">
                <i class="fa fa-trash-o"></i>
                删除分类
            </button>
            @endcan
        </div>
    </div>
</div>
<!-- 节点操作询问层 -->

<!-- 分类编辑层 -->
<div class="ibox-content" id="box-form" style="display: none">
    <form id="form" method="POST" class="form-horizontal">
        <input type="hidden" name="cat_id" id="cat_id"  v-model="curCatData.cat_id">
        <input type="hidden" name="parent_id" id="parent_id"  v-model="curCatData.parent_id">
        <input type="hidden" name="material_type" id="material_type"  v-model="curCatData.material_type">
        <div class="form-group">
            <label class="col-sm-2 control-label">分类名</label>
            <div class="col-sm-10">
                <input type="text" name="name" id="name" v-model="curCatData.name" class="form-control">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">描述</label>
            <div class="col-sm-10">
                <textarea class="form-control" placeholder="输入描述" name="description" id="description" v-model="curCatData.description"></textarea>
                <span class="help-block m-b-none">分类说明</span>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">排序</label>
            <div class="col-sm-4">
                <input type="number" min="1" step="1" name="order_num" id="order_num" value="999"  v-model="curCatData.order_num" class="form-control">
                <span class="help-block m-b-none">数字越小越靠前</span>
            </div>
        </div>
        <div class="hr-line-dashed"></div>
        <div class="form-group">
            <div class="col-sm-4 col-sm-offset-4">
                <button class="btn btn-primary" type="button" id="btn-sub" v-on:click="save">
                    保存
                </button>
            </div>
        </div>
    </form>
</div>
<!-- 分类编辑层 -->
@endsection